import { IPSAppDEAction } from '../dataentity/ipsapp-deaction';
import { IPSAppDEField } from '../dataentity/ipsapp-defield';
import { IPSAppDataEntity } from '../dataentity/ipsapp-data-entity';
import { IPSAppDERedirectView } from './ipsapp-deredirect-view';
import { IPSAppViewRef } from './ipsapp-view-ref';
import { PSAppDEViewImpl } from './psapp-deview-impl';

export class PSAppDERedirectViewImpl extends PSAppDEViewImpl implements IPSAppDERedirectView {
  protected getdatapsappdeaction: IPSAppDEAction | null = null;

  getGetDataPSAppDEAction(): IPSAppDEAction | null {
    if (this.getdatapsappdeaction != null) return this.getdatapsappdeaction;
    const value = this.M.getGetDataPSAppDEAction;
    if (value == null) {
      return null;
    }
    const ipsappdataentity = this.getPSAppDataEntity();
    if (ipsappdataentity != null) {
      this.getdatapsappdeaction = ipsappdataentity.findPSAppDEAction(value);
    }
    return this.getdatapsappdeaction;
  }

  get getDataPSAppDEAction(): IPSAppDEAction | null {
    return this.getGetDataPSAppDEAction();
  }

  getGetDataPSAppDEActionMust(): IPSAppDEAction {
    const value = this.getGetDataPSAppDEAction();
    if (value == null) {
      throw new Error('未指定获取数据应用实体行为');
    }
    return value;
  }

  protected redirectpsappviewrefs: IPSAppViewRef[] | null = null;

  getRedirectPSAppViewRefs(): IPSAppViewRef[] | null {
    if (this.redirectpsappviewrefs == null) {
      this.redirectpsappviewrefs = this.fillChildListModel(this.M.getRedirectPSAppViewRefs, 'app.view.IPSAppViewRef') as IPSAppViewRef[];
    }
    return this.redirectpsappviewrefs;
  }

  get redirectPSAppViewRefs(): IPSAppViewRef[] | null {
    return this.getRedirectPSAppViewRefs();
  }

  findRedirectPSAppViewRef(objKey: any): IPSAppViewRef | null {
    return this.getPSModel5('app.view.IPSAppViewRef', this.getRedirectPSAppViewRefs(), objKey) as IPSAppViewRef;
  }

  protected typepsappdefield: IPSAppDEField | null = null;

  getTypePSAppDEField(): IPSAppDEField | null {
    if (this.typepsappdefield != null) return this.typepsappdefield;
    const value = this.M.getTypePSAppDEField;
    if (value == null) {
      return null;
    }
    const ipsappdataentity = this.getPSAppDataEntity();
    if (ipsappdataentity != null) {
      this.typepsappdefield = ipsappdataentity.findPSAppDEField(value);
    }
    return this.typepsappdefield;
  }

  get typePSAppDEField(): IPSAppDEField | null {
    return this.getTypePSAppDEField();
  }

  getTypePSAppDEFieldMust(): IPSAppDEField {
    const value = this.getTypePSAppDEField();
    if (value == null) {
      throw new Error('未指定应用实体数据类型识别属性');
    }
    return value;
  }

  get enableCustomGetDataAction(): boolean {
    return this.M.enableCustomGetDataAction;
  }

  get enableWorkflow(): boolean {
    return this.M.enableWorkflow;
  }

  get redirectView(): boolean {
    return this.M.redirectView;
  }

  get cls(): string {
    return 'PSAppDERedirectViewImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'app.view.IPSAppDERedirectView' || cls == 'app.view.IPSAppRedirectView') return true;
    return super.instanceof(cls);
  }
}
